package com.xzh.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xzh.dao.TeachersMapper;
import com.xzh.model.Teachers;
import com.xzh.service.TeachersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TeachersServiceImpl implements TeachersService {
    private TeachersMapper teachersMapper;
    @Autowired
    public void setTeachersMapper(TeachersMapper teachersMapper) {
        this.teachersMapper = teachersMapper;
    }
    @Override
    public Page<Teachers> selectAll(Page<Teachers> page, Teachers teachers) {
        return teachersMapper.selectAll(page, teachers);
    }

    @Override
    public boolean save(Teachers teachers) {
        return teachersMapper.insert(teachers) > 0;
    }

    @Override
    public boolean updateById(Teachers teachers) {
        return teachersMapper.updateById(teachers) > 0;
    }

    @Override
    public int deleteByIds(List<Integer> ids) {
        return teachersMapper.deleteByIds(ids);
    }

    @Cacheable(value = "teacherStats", key = "'titleDistribution'")
    @Override
    public List<Map<String, Object>> statistics() {
        return teachersMapper.statistics();
    }
}
